package fragment;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import com.qianfeng.lingshijia.R;

import java.util.ArrayList;
import java.util.List;

import adapter.MessageListViewAdapter;

public class PersonFeedBackActivity extends AppCompatActivity implements View.OnClickListener {

    ListView listView;
    EditText message_edit;
    TextView send_message;
    List<String> data;
    MessageListViewAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person_feed_back);
        initView();
    }

    private void initView()
    {
        data = new ArrayList<>();
         listView = (ListView) findViewById(R.id.message_list);
         adapter = new MessageListViewAdapter(data,this);
        listView.setAdapter(adapter);

         message_edit = (EditText) findViewById(R.id.message_ed);
         send_message = (TextView) findViewById(R.id.send_tv);
        send_message.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
       String message = message_edit.getText().toString();
        if (!TextUtils.isEmpty(message))
        {
            data.add(message);
            adapter.notifyDataSetChanged();
            listView.setSelection(listView.getBottom());
            message_edit.setText("");
        }
    }

    public void back(View view)
    {
        this.finish();
    }
}
